package com.superjson.showpro.controller.core;

import com.superjson.showpro.entity.User;
import com.superjson.showpro.shared.exception.GeneralBizException;
import com.superjson.showpro.shared.result.Result;
import com.superjson.showpro.shared.result.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import static com.superjson.showpro.constants.SessionConstant.SESSION_USER;
import static com.superjson.showpro.constants.SessionConstant.TOKEN;
import static com.superjson.showpro.shared.result.ResultCodeEnum.USER_LOGIN_EXCEPTION;
import static com.superjson.showpro.shared.result.ResultCodeEnum.USER_NO_LOGIN;
import static java.util.Objects.isNull;

/**
 * Created By zby on 0:02 2019/6/18
 * <p>
 * 这是基本的控制层
 */

public class BaseContoller {

    public final Logger logger = LoggerFactory.getLogger(getClass().getName());

    /**
     * Created By zby on 0:04 2019/6/18
     * 获取登录人的信息
     *
     * @param request 请求对象
     */
    public Result<User> getUser(HttpServletRequest request) {
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute(SESSION_USER);
        return ResultUtil.buildSuccess(user);
    }

}
